<template>
  <a-card :bordered="false">
    <a-tabs>
      <a-tab-pane :tab="whole" key="erp">
        <erp-template />
      </a-tab-pane>
      <a-tab-pane :tab="takingOrders" key="1">
        <template1 />
      </a-tab-pane>
      <a-tab-pane :tab="appointment" key="2">
        <template2 />
      </a-tab-pane>
      <a-tab-pane :tab="signIn" key="3">
        <template3 />
      </a-tab-pane>
      <a-tab-pane :tab="handle" key="4">
        <template4 />
      </a-tab-pane>
      <a-tab-pane :tab="pendingReview" key="5">
        <template5 />
      </a-tab-pane>
	  <a-tab-pane :tab="followUp" key="6">
        <template6 />
      </a-tab-pane>
	  <a-tab-pane :tab="followedUp" key="7">
        <template7 />
      </a-tab-pane>
    </a-tabs>
  </a-card>
</template>

<script lang="ts" setup>
import {ref} from 'vue';
import {queryStatistics} from './workOrder/WorkOrder.api';
  import Template1 from './workOrder3/WorkOrderList.vue';
  import Template2 from './workOrder15/WorkOrderList.vue';
  import Template3 from './workOrder16/WorkOrderList.vue';
  import Template4 from './workOrder17/WorkOrderList.vue';
  import Template5 from './workOrder9/WorkOrderList.vue';
  import Template6 from './workOrder12/WorkOrderList.vue';
  import Template7 from './workOrder13/WorkOrderList.vue';
  import ErpTemplate from './workOrder/WorkOrderList.vue';
import { usePermission } from '/@/hooks/web/usePermission';
const { hasPermission } = usePermission();
const whole = ref('全部');
const takingOrders = ref('待接单');
const appointment = ref('待预约');
const signIn = ref('待签到');
const handle = ref('待处理');
const pendingReview = ref('待审核');
const followUp = ref('待回访');
const followedUp = ref('已回访');

if(hasPermission('workOrder:add')){
  batchHandleDelete({userFlag:0});
  setInterval(() => {
    batchHandleDelete({userFlag:0});
  }, 5000);
}else{
  batchHandleDelete({userFlag:1});
  setInterval(() => {
    batchHandleDelete({userFlag:1});
  }, 5000);
}

async function batchHandleDelete(params) {
  const statistics = queryStatistics(params);
  statistics.then((res) => {
    whole.value='全部（'+res.whole+'）'
    takingOrders.value='待接单（'+res.takingOrders+'）'
    appointment.value='待预约（'+res.appointment+'）'
    signIn.value='待签到（'+res.signIn+'）'
    handle.value='待处理（'+res.handle+'）'
    pendingReview.value='待审核（'+res.pendingReview+'）'
    followUp.value='待回访（'+res.followUp+'）'
    followedUp.value='已回访（'+res.followedUp+'）'
  });
}
/**
 * 成功回调
 */
// function handleSuccess() {
//   (selectedRowKeys.value = []) && reload();
// }
</script>

<style scoped></style>
